home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / gs262 / gspaint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  3.3 KB  |  113 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gspaint.c */
  20. /* Painting procedures for Ghostscript library */
  21. #include "gx.h"
  22. #include "gpcheck.h"
  23. #include "gserrors.h"
  24. #include "gxfixed.h"
  25. #include "gxmatrix.h"            /* for gs_state */
  26. #include "gspaint.h"
  27. #include "gzpath.h"
  28. #include "gzstate.h"
  29. #include "gzdevice.h"
  30. #include "gzcolor.h"
  31. #include "gxcpath.h"
  32. #include "gxdevmem.h"
  33. #include "gximage.h"
  34.  
  35. #ifdef AMIGA
  36. extern int gx_color_load(gx_device_color *, const gs_state *);
  37. extern int gx_fill_path(gx_path *, gx_device_color *, gs_state *, int, fixed);
  38. extern int gs_newpath(gs_state *);
  39. extern int gx_stroke_fill(const gx_path *, gs_state *);
  40. extern int gx_stroke_add(const gx_path *, gx_path *, gs_state *);
  41. #endif
  42.  
  43. /* Erase the page */
  44. int
  45. gs_erasepage(gs_state *pgs)
  46. {    device *pdev = pgs->device;
  47.     gx_device *dev = pdev->info;
  48.     return (*dev->procs->fill_rectangle)(dev, 0, 0, dev->width, dev->height, pdev->white);
  49. }
  50.  
  51. /* Fill using the winding number rule */
  52. int
  53. gs_fill(gs_state *pgs)
  54. {    int code;
  55.     /* If we're inside a charpath, just merge the current path */
  56.     /* into the parent's path. */
  57.     if ( pgs->in_charpath )
  58.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  59.     else
  60.        {    gx_color_load(pgs->dev_color, pgs);
  61.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  62.                     gx_rule_winding_number, fixed_0);
  63.         if ( !code ) gs_newpath(pgs);
  64.        }
  65.     return code;
  66. }
  67.  
  68. /* Fill using the even/odd rule */
  69. int
  70. gs_eofill(gs_state *pgs)
  71. {    int code;
  72.     /* If we're inside a charpath, just merge the current path */
  73.     /* into the parent's path. */
  74.     if ( pgs->in_charpath )
  75.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  76.     else
  77.        {    gx_color_load(pgs->dev_color, pgs);
  78.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  79.                     gx_rule_even_odd, fixed_0);
  80.         if ( !code ) gs_newpath(pgs);
  81.        }
  82.     return code;
  83. }
  84.  
  85. /* Stroke the current path */
  86. int
  87. gs_stroke(gs_state *pgs)
  88. {    int code;
  89.     /* If we're inside a charpath, just merge the current path */
  90.     /* into the parent's path. */
  91.     if ( pgs->in_charpath )
  92.         code = gx_path_add_path(pgs->show_gstate->path, pgs->path);
  93.     else
  94.        {    gx_color_load(pgs->dev_color, pgs);
  95.         code = gx_stroke_fill(pgs->path, pgs);
  96.         if ( !code ) gs_newpath(pgs);
  97.        }
  98.     return code;
  99. }
  100.  
  101. /* Compute the stroked outline of the current path */
  102. int
  103. gs_strokepath(gs_state *pgs)
  104. {    gx_path spath;
  105.     int code;
  106.     gx_path_init(&spath, pgs->memory_procs);
  107.     code = gx_stroke_add(pgs->path, &spath, pgs);
  108.     if ( code < 0 ) return code;
  109.     gx_path_release(pgs->path);
  110.     *pgs->path = spath;
  111.     return 0;
  112. }
  113.